# coding:utf8
from random import randint

target = randint(0, 100)
recordGuess = []


# 逻辑判断
def judge(guess):
    guess = int(guess)
    if guess == target:
        print ('噢耶！答对了哦')
        return True
    elif guess > target:
        print ('too big')
    else:
        print ('too small')
    return False


# 记录功能
def record(guess):
    recordGuess.append(guess)


# 辅助功能
def help(guess):
    if guess == 'target':
        print(target)
        print("GAME OVER")
        return False
    elif guess == 'record':
        for i in recordGuess:
            print(i)
        doit()
    else:
        return True


# 递归执行
def doit():
    guess = raw_input('请输入你的猜想 ')
    record(guess)
    h = help(guess)
    if h:
        pass
    else:
        return
    result = judge(guess)
    if result:
        return
    else:
        doit()


# doit()




from collections import deque

history = deque([])
history.append({"name": "shisongyan"})
history.append({"name": "cailele"})
history.append({"name": "cailele"})
history.append({"name": "cailele"})
history.append({"name": "cailele"})

print(history)

import pickle

pickle.dump(history, open('history.txt', 'w'))
h = pickle.load(open('history.txt'))
print h[0]
for i in h:
    print i.keys()
